package com.jh.netty.opaqueopacimeter;

//import com.jh.commons.protocol.RadixUtil;

import java.util.List;

import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

/**
 * 16 进制 转二进制
 * @see io.netty.handler.codec.string.StringEncoder
 */
public class HexStringEncoder extends MessageToMessageEncoder<CharSequence> {
    @Override
    protected void encode(ChannelHandlerContext ctx, CharSequence msg, List<Object> out) throws Exception {
        byte[] bytes = RadixUtil.hexString2Bytes(msg.toString());
        out.add(Unpooled.wrappedBuffer(bytes));
    }
}
